package com.service;

import com.dao.EmployeeDao;
import com.entity.Employee;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Data // 构建 set 方法
@Service // 声明自己是 Service
public class EmployeeServiceImpl implements EmployeeService {
    @Autowired // 自动装配
    private EmployeeDao employeeDao;  // 依赖接口

    @Override
    public List<Employee> selectEmployeeAll() {
        return employeeDao.selectEmployeeAll();
    }

    @Override
    public Employee selectEmployeeById(int id) {
        return employeeDao.selectEmployeeById(id);
    }

    @Override
    public Boolean insertEmployee(Employee employee) {
        return employeeDao.insertEmployee(employee) > 0;
    }

    @Override
    public Boolean deleteEmployeeById(int id) {
        return employeeDao.deleteEmployeeById(id) > 0;
    }

    @Override
    public Boolean updateEmployeeById(Employee employee) {
        return employeeDao.updateEmployeeById(employee) > 0;
    }

}
